Python - Recursive Function example.py


Sign up Free. Don't forget to check out our challenges, lessons, solve and learn series and more ...


Code Snippet

#This is an example of RECURSION (a recursive function)
#Can you spot the recursion? (which line?)
#What's wrong with this function?!
#How can you fix the problem!!! Every recursive function MUST HAVE A....?!?!? B___C___ or S______ C________

def moose(n):
        return n + moose(n)
                    

Try it yourself